|
ARD2
RC2
Airbag Reference Demonstrator using MPC5604P
|
00001 00016 #include "derivative.h" 00017 #include "SWT.h" 00018 /* 00019 ****************************************************************************** 00020 * Constants 00021 ****************************************************************************** 00022 */ 00023 /* 00024 ****************************************************************************** 00025 * Globals 00026 ****************************************************************************** 00027 */ 00028 00029 /* 00030 ****************************************************************************** 00031 * u16fnConfigSoftwareWatchDog 00032 ****************************************************************************** 00033 */ 00034 uint16_t u16fnConfigSoftwareWatchDog(const SWTConfig_t* ptMySWTConfig) 00035 { 00036 uint16_t u16Status; 00037 uint32_t u32RegisterValue; 00038 00039 u16Status = CLEAR; 00040 00041 /* Check to see where we're at with regards to the lock */ 00042 u16Status = u16fnSWTLockStatus(); 00043 switch(u16Status) 00044 { 00045 case(SWT_SOFT_LOCKED): 00046 { 00047 /* Clear lock */ 00048 SWT_CLEAR_SOFT_LOCK(); 00049 /* Trickle down to the next case */ 00050 } 00051 case(SWT_UNLOCKED): 00052 { 00053 /* Configure the module */ 00054 SWT.WN.R = ptMySWTConfig->W.WindowCount; 00055 SWT.TO.R = ptMySWTConfig->W.TimeOutCount; 00056 u32RegisterValue = ptMySWTConfig->W.CR; 00057 SWT.CR.R = (SWT_DEFAULT_MAP_SETTING | u32RegisterValue); 00058 break; 00059 } 00060 default: 00061 { 00062 /* Nothing to do */ 00063 } 00064 }; 00065 00066 return(u16Status); 00067 } 00068 /* 00069 ****************************************************************************** 00070 * u16fnSWTLockStatus 00071 ****************************************************************************** 00072 */ 00073 static uint16_t u16fnSWTLockStatus(void) 00074 { 00075 /* Declare local variables */ 00076 uint16_t u16Status; 00077 00078 /* Init local variables */ 00079 u16Status = SWT_UNLOCKED; 00080 00081 /* Check to see if the module is soft-locked */ 00082 if(CLEAR == SWT.CR.B.SLK) 00083 { 00084 /* We're still good */ 00085 } 00086 else 00087 { 00088 u16Status |= SWT_SOFT_LOCKED; 00089 } 00090 00091 /* Check to see if the module is hard-locked */ 00092 if(CLEAR == SWT.CR.B.HLK) 00093 { 00094 /* We're still good */ 00095 } 00096 else 00097 { 00098 u16Status |= SWT_HARD_LOCKED; 00099 } 00100 return(u16Status); 00101 } 00102 00103 /* 00104 ****************************************************************************** 00105 * 00106 * End of file. 00107 * 00108 ****************************************************************************** 00109 */